package top.riske.gen3d.common.DTO;

import lombok.Data;
import top.riske.gen3d.enums.RoleEnum;

import java.time.LocalDateTime;

/**
 * jwt
 * created by vital on 2025/3/1 下午3:39
 */
@Data
public class JwtDto {

    /**
     * token
     */
    private String token;

    /**
     * 用户id
     */
    private Long uid;

    /**
     * 角色
     */
    private RoleEnum role;

    /**
     * 过期时间
     */
    private LocalDateTime expiresAt;

    /**
     * 是否过期
     */
    private Boolean expired;

    public JwtDto() {
    }

    public JwtDto(String token) {
        this.token = token;
        this.expired = null;
    }

    public JwtDto(String token, Long uid, RoleEnum role, LocalDateTime expiresAt) {
        this.token = token;
        this.uid = uid;
        this.role = role;
        this.expiresAt = expiresAt;
        this.expired = LocalDateTime.now().isAfter(expiresAt);
    }
}
